// Lindsay Gilmour
// Adam Lusch
// Dan Niceswanger
//
// Computer Graphics Project 1:
// Asteroids!
// A Tribute

#include "CollisionHandler.h"

CollisionHandler::CollisionHandler()
	: b2ContactListener()
{
}

CollisionHandler::~CollisionHandler()
{
	map<int32, b2ContactPoint*>::iterator iter = contactList.begin();
	for (; iter != contactList.end(); ++iter)
	{
		delete iter->second;
	}
}

void CollisionHandler::Add(const b2ContactPoint* point)
{
	contactList[point->id.key] = new b2ContactPoint(*point);
}

void CollisionHandler::Remove(const b2ContactPoint* point)
{
	map<int32, b2ContactPoint*>::iterator iter = contactList.find(point->id.key);
	if(iter != contactList.end())
	{
		delete iter->second;
		contactList.erase(iter);
	}
}

const map<int32, b2ContactPoint*>& CollisionHandler::getContacts() const
{
	return contactList;
}
